package org.xhy.security.token;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

public class SmsAuthenticationToken extends AbstractAuthenticationToken {

    /*做序列化*/
    private static final long serialVersionUID = 500L;
    // 用户名      手机号
    private String phone;

    //认证成功前用
    public SmsAuthenticationToken(String phone) {
        super((Collection)null);
        this.phone = phone;
        //是否认证成功
        this.setAuthenticated(false);
    }

    //认证成功后用
    public SmsAuthenticationToken(String phone,  Collection<GrantedAuthority> authorities) {
        super(authorities);
        this.phone = phone;
        super.setAuthenticated(true);
    }

    @Override
    public Object getCredentials() {
        return "";
    }

    @Override
    public Object getPrincipal() {
        return phone;
    }
}
